package com.cjx.stars.controller;

import com.cjx.stars.common.MyException;
import com.cjx.stars.common.Response;
import com.cjx.stars.pojo.request.ChatRequest;
import com.cjx.stars.pojo.vo.ChatMessageVO;
import com.cjx.stars.service.ChatService;
import com.cjx.stars.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

import static com.cjx.stars.constant.ChatConstant.*;
import static com.cjx.stars.constant.FailMessage.ERROR_PARAMETER_IS_BLACK;

/**
 * @author cjx
 * @description 聊天功能控制类
 * @createDate 2024/4/13 20:06
 **/
@RestController
@RequestMapping("/chat")
@Api(tags = "聊天管理模块")
public class ChatController {
    /**
     * 聊天服务
     */
    @Resource
    private ChatService chatService;

    /**
     * 用户服务
     */
    @Resource
    private UserService userService;


    @PostMapping("/privateChat")
    @ApiOperation(value = "获取私聊数据")
    @ApiImplicitParams(
            {@ApiImplicitParam(name = "chatRequest",
                    value = "聊天请求")})
    public Response<?> getPrivateChat(@RequestBody ChatRequest chatRequest) {
        if (chatRequest == null) {
            throw new MyException(ERROR_PARAMETER_IS_BLACK);
        }
        return  chatService.getPrivateChat(chatRequest, PRIVATE_CHAT);
    }

    @PostMapping("/teamChat")
    @ApiOperation(value = "获取队伍聊天")
    @ApiImplicitParams(
            {@ApiImplicitParam(name = "chatRequest",
                    value = "聊天请求")})
    public Response<?> getTeamChat(@RequestBody ChatRequest chatRequest) {
        if (chatRequest == null) {
            throw new MyException(ERROR_PARAMETER_IS_BLACK);
        }
        return chatService.getTeamChat(chatRequest, TEAM_CHAT);
    }


    @GetMapping("/hallChat")
    @ApiOperation(value = "获取大厅聊天")
    public  Response<?> getHallChat() {
        return chatService.getHallChat(HALL_CHAT);
    }


}